<template>
  <div class="header_main">
    <div class="header_logo">
      <img src="../assets/logo.jpg" class="header_logo_img" />
      <span class="header_logo_txt">阿柒的博客</span>
    </div>
    <div class="mobile-menu">
      <el-dropdown  @command="handleClick">
        <i class="el-icon-circle-plus-outline mobile-menu-button"></i>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="1"><i class="el-icon-s-home"></i>首页</el-dropdown-item>
            <el-dropdown-item command="2"><i class="el-icon-user"></i>关于</el-dropdown-item>
            <el-dropdown-item command="3">
              <font-awesome-icon :icon="['fab', 'github']"></font-awesome-icon>
              码云
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>

    <div class="header_link">
      <el-button icon="el-icon-s-home" type="text" @click="this.$router.push('/')">首页</el-button>
      <el-button icon="el-icon-user" type="text" @click="this.$router.push('/about')">关于</el-button>
      <el-button type="text" @click="goGit">
          <font-awesome-icon :icon="['fab', 'github']" style="margin-right: 5px;width: 16px;height: 16px"></font-awesome-icon>
          <span style="height: 17px;line-height: 1;display: inline-block;vertical-align: bottom">码云</span>
      </el-button>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
import {Router, useRouter} from "vue-router";

export default defineComponent({
  name: "Header",
  setup() {
    const goGit = () => {
      window.open('https://gitee.com/xiaogegeya','_blank')
    }
    const router:Router = useRouter()
    const handleClick = (command: string) => {
      if(command === '1') {
        router.push({path: '/'})
      }else if(command === '2') {
        router.push({path: '/about'})
      }else {
        window.open('https://gitee.com/xiaogegeya','_blank')
      }
    }
    return {
      goGit,
      handleClick
    }
  }
})
</script>

<style scoped>
@media screen and (min-width: 751px){
  .header_main {
    display: flex;
    height: 2.2rem;
    padding: .7rem 1.5rem;
    background-color: white;
    box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.1);
  }
  .mobile-menu {
    display: none;
  }
  .header_link {
    display: flex;
    justify-content: right;
    margin-left: auto;
    margin-right: 2rem;
  }
}
/* 移动端 */
@media screen and (max-width: 750px){
  .header_main {
    display: flex;
    height: 2rem;
    padding: 0.5rem;
    background-color: white;
    box-shadow: 0 1px 8px 0 rgba(0, 0, 0, 0.1);
    align-items: center;
  }
  .mobile-menu {
    display: block;
    justify-content: right;
    margin-left: auto;
    margin-right: 0!important;
  }
  .mobile-menu-button {
    font-size: 1.5rem!important;
  }
  .header_link {
    display: none;
  }
}
.header_logo {
  display: flex;
  line-height: 2.2rem;
  align-items: center;
}
.header_logo_img {
  width: 2.2rem;
  height: 2.2rem;
  margin-right: .8rem;
}
.header_logo_txt {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 2px;
}
/deep/ .el-button {
  font-size: 1rem;
  margin-right: 1rem;
  color:black
}
/deep/ .el-button:hover {
  color: gray!important;
}
</style>
